﻿@model LS.Models.CardManageModel


<div class="modal-body">
    @using (Html.BeginForm()) {
        @Html.AntiForgeryToken()
        @Html.ValidationSummary(true)
        
        @*<div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <h3 id="myModalLabel">Card</h3>
        </div>*@
        <fieldset>
            <div class="control-group">
                <label class="control-label">@Html.DisplayNameFor(model => model.Card.SeiralNumber)</label>
                <div class="controls">
                    <input class="input-xlarge uneditable-input" id="disabledInput" value="@Html.DisplayFor(model => model.Card.SeiralNumber)" placeholder="@Html.DisplayFor(model => model.Card.SeiralNumber)" disabled="">
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">@Html.DisplayNameFor(model => model.Description)</label>
                <div class="controls">
                    @*<input type="text" placeholder="Description" value="@Html.DisplayFor(model => model.Description)">*@
                    @Html.EditorFor(model => model.Description, new { placeholder = "Description" })
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">@Html.DisplayNameFor(model => model.ExpireDate)</label>
                <div class="controls">
                    <input class="input-xlarge disabled" type="date" placeholder="ExpireDate" value="@Html.DisplayFor(model => model.ExpireDate)" disabled="">
                    @*<button type="submit" class="btn btn-primary">Renew</button>*@
                    @Html.ActionLink("Renew", "Renew", new { MemberCardId = Model.MemberCardId }, new { @class = "btn" })
                </div>
            </div>
            @*            <div class="control-group">
                <div class="controls">
                    <input type="submit" value="Save" class="btn btn-primary" />
                </div>
            </div>*@
            <div class="modal-footer">
                <input type="button" value="Save" class="btn btn-primary" onclick="DoAjaxPostAndMore(this)" data-dismiss="modal" aria-hidden="true"/>
                <button class="btn btn-inverse" data-dismiss="modal" aria-hidden="true">Close</button>
            </div>
        </fieldset>
    }
</div>

<script type="text/javascript">
    function DoAjaxPostAndMore(btnClicked) {
        var $form = $(btnClicked).parents('form');

        $.ajax({
            type: "POST",
            url: $form.attr('action'),
            data: $form.serialize(),
            error: function (xhr, status, error) {
                //do something about the error
            },
            success: function (response) {
                //do something with response
                //alert(response.s);
                //alert(response.Id);
                LoadMyCards(response);
            }
        });

        return false;// if it's a link to prevent post

    }
</script>

